package com.test.chatrobot3.test;

public class TextCleaner {
    public static String cleanText(String text) {
        // 转换为小写
        text = text.toLowerCase();
        // 去除标点符号
        text = text.replaceAll("[^a-zA-Z0-9\\s]", "");
        // 去除多余空格
        text = text.replaceAll("\\s+", " ").trim();
        return text;
    }

    public static void main(String[] args) {
        String dirtyText = "Hello, World!  This is a test.";
        String cleanText = cleanText(dirtyText);
        System.out.println(cleanText);  // 输出: hello world this is a test
    }
}